<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use App\Http\Requests\CommentRequest;
use App\Models\Goods;
use Auth;

class GoodsCommentController extends Controller
{
    public function index(Goods $goods) {
    	$comments = $goods->comments()->paginate();
    	return $comments;
    }

    public function store(Goods $good, CommentRequest $request) {

    	$comment = Auth::user()->comments()->firstOrNew($request->input()); 
    	$good->comments()->save($comment);
    	return response()->json(['status' => 0, 'msg' => '评论成功']);
    }
}
